home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Temperature / CTemperatureApp.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  3.9 KB  |  191 lines  |  [TEXT/CWIE]

  1. // CTemperatureApp.cp -- application methods
  2.  
  3. #include "CTemperatureApp.h"
  4.  
  5. #include "CTemperatureDoc.h"
  6. #include "CTemperatureData.h"
  7.  
  8. #include "TemperatureCmds.h"
  9.  
  10. #include <Appearance.h>
  11. #include <UDesktop.h>
  12. #include <UEnvironment.h>
  13. #include <URegistrar.h>
  14. #include <UScreenPort.h>
  15. #include <PPobClasses.h>
  16. #include <PP_Messages.h>
  17.  
  18. // ---------------------------------------------------------------------------
  19. //        • CTemperatureApp
  20. // ---------------------------------------------------------------------------
  21. //    Default constructor
  22.  
  23. CTemperatureApp::CTemperatureApp()
  24.     :LDocApplication()
  25. {
  26.     UEnvironment::InitEnvironment ();
  27.     if (UEnvironment::HasFeature (env_HasAppearance)) {
  28.         ::RegisterAppearanceClient ();
  29.     }
  30.  
  31.     UScreenPort::Initialize();
  32.  
  33.     RegisterClasses();
  34.  
  35.     SetUpMenus();
  36.  
  37.     // initialize app's data:
  38.  
  39. }
  40.  
  41.  
  42. // ---------------------------------------------------------------------------
  43. //        • ~CTemperatureApp
  44. // ---------------------------------------------------------------------------
  45. //    Destructor
  46. //
  47.  
  48. CTemperatureApp::~CTemperatureApp()
  49. {
  50. }
  51.  
  52. // ---------------------------------------------------------------------------
  53. //        • RegisterClasses
  54. // ---------------------------------------------------------------------------
  55. //
  56.  
  57. void
  58. CTemperatureApp::RegisterClasses()
  59. {
  60. //x    RegisterAllPPClasses();
  61.             // replaced to register only classes that we use.
  62.             // windows know what classes they use
  63.             // so call static functions in each window/dialog,
  64. }
  65.  
  66. // ---------------------------------------------------------------------------
  67. //        • SetUpMenus
  68. // ---------------------------------------------------------------------------
  69. //
  70.  
  71. void
  72. CTemperatureApp::SetUpMenus()
  73. {
  74.  
  75. }
  76.  
  77. // ---------------------------------------------------------------------------
  78. //        • StartUp
  79. // ---------------------------------------------------------------------------
  80. //    The application calls this member function automatically when the application
  81. //    is opened
  82.  
  83. void
  84. CTemperatureApp::StartUp()
  85. {
  86.     ObeyCommand(cmd_New, nil);
  87. }
  88.  
  89. //----------
  90. LModelObject*
  91. CTemperatureApp::MakeNewDocument()
  92. {
  93.     CTemperatureDoc    *theDoc = new CTemperatureDoc(this);
  94.  
  95.     theDoc->newFile();
  96.  
  97.     return theDoc;
  98. }
  99.  
  100. //----------
  101. // called from SendAEOpenDoc in response to Open command
  102.  
  103. void
  104. CTemperatureApp::OpenDocument(
  105.     FSSpec    *inMacFSSpec)
  106. {
  107.     CTemperatureDoc    *theDoc = new CTemperatureDoc(this);
  108.  
  109.     theDoc->openFile (inMacFSSpec);
  110. }
  111.  
  112. //----------
  113. // called from LDocApplication in response to Open command
  114.  
  115. void
  116. CTemperatureApp::ChooseDocument()
  117. {
  118.     SFTypeList            typeList;
  119.     short                numTypes;
  120.     StandardFileReply    macFileReply;
  121.  
  122.     typeList[0] = kFileType;
  123.     numTypes = 1;
  124.  
  125.     UDesktop::Deactivate();
  126.     ::StandardGetFile(nil, numTypes, typeList, &macFileReply);
  127.     UDesktop::Activate();
  128.  
  129.     if (macFileReply.sfGood) {
  130.         SendAEOpenDoc(macFileReply.sfFile);
  131.     }
  132. }
  133.  
  134. // ---------------------------------------------------------------------------
  135. //        • ObeyCommand
  136. // ---------------------------------------------------------------------------
  137. //    Respond to commands
  138.  
  139. Boolean
  140. CTemperatureApp::ObeyCommand(
  141.     CommandT    inCommand,
  142.     void*        ioParam)
  143. {
  144.     Boolean        cmdHandled = true;
  145.  
  146.     if (inCommand < 0) {
  147.         // modal dialog has finished
  148.  
  149.         switch (-inCommand) {
  150.         }
  151.  
  152.     } else {
  153.         switch (inCommand) {
  154.  
  155.         default:
  156.                 cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  157.             break;
  158.         }
  159.     }
  160.  
  161.     return cmdHandled;
  162. }
  163.  
  164.  
  165. // ---------------------------------------------------------------------------
  166. //        • FindCommandStatus
  167. // ---------------------------------------------------------------------------
  168. //    Pass back status of a (menu) command
  169.  
  170. void
  171. CTemperatureApp::FindCommandStatus(
  172.     CommandT    inCommand,
  173.     Boolean        &outEnabled,
  174.     Boolean        &outUsesMark,
  175.     Char16        &outMark,
  176.     Str255        outName)
  177. {
  178.     outUsesMark = false;
  179.  
  180.     switch (inCommand) {
  181.  
  182.     // +++ Add cases here for the commands you handle
  183.  
  184.  
  185.     default:
  186.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  187.                                                 outMark, outName);
  188.         break;
  189.     }
  190. }
  191.